package com.esiag.isidis.fi.pdsteam.random;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import com.esiag.pdsteam.referencement.bean.Message;
import com.esiag.pdsteam.referencement.bean.Source;

public class Randomizer {

	public static ArrayList<Source> rand(int eventCount, Set<Source> sensors) {
		Object tSensors[] = sensors.toArray();
		Set<Source> rSensors =new HashSet<Source>();
		ArrayList<Source> sources = new ArrayList<Source>();
		for( int i=0; i<eventCount; i++){
			sources.add((Source)tSensors[random(0, tSensors.length)]);
		}
		return sources;
	}

	public static Message rand(Set<Message> messages) {
		Object tMessages[] = messages.toArray();
		return  (Message) tMessages[ random(0, tMessages.length)];
	}

	static int random(int min, int max){
		return min + (int)(Math.random()*max);
	}

}
